package com.wshl.aijiuunion.controller.activity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.utilcode.util.GsonUtils;
import com.lzy.okgo.OkGo;
import com.wshl.aijiuunion.BaseActivity;
import com.wshl.aijiuunion.R;
import com.wshl.aijiuunion.callback.RequestCallback;
import com.wshl.aijiuunion.model.RequestModel;
import com.wshl.aijiuunion.view.bean.XieyiBean;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created buy 风凊扬 on 2019/11/20 0020
 * 用户协议
 */
public class UserXieyiActivity extends BaseActivity {
    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.tv_top_title)
    TextView tvTopTitle;
    @BindView(R.id.tv_content)
    TextView tvContent;

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_xieyi;
    }

    private RequestModel requestModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);
        tvTopTitle.setText("用户协议和隐私条款");

        requestModel = new RequestModel();
        requestModel.xieYi(this, new RequestCallback() {
            @Override
            public void onSuccess(String response) {


                XieyiBean xieyiBean = GsonUtils.fromJson(response, XieyiBean.class);
                XieyiBean.DataBean data = xieyiBean.getData();

                String title = data.getTitle();
                String content = data.getContent();

                tvTopTitle.setText(title);
                tvContent.setText(content);


            }

            @Override
            public void onError(int code) {

            }

            @Override
            public void onIntentError() {

            }
        });

    }

    @OnClick(R.id.img_back)
    public void onViewClicked() {
        this.finish();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        OkGo.getInstance().cancelAll();
    }
}
